<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        // promise 的单一状态 和 状态中转
        // promise 一旦状态变化了 就不能再次改变
        new Promise((resolve, reject) => {
            resolve('成功状态')
            reject('拒绝状态')
        }).then(value => {
            console.log(value) 
        }, reason => {
            console.log(reason)
        })

        //上面代码一旦resolve 了 promise 就不能 reject 了


        let p1 = new Promise((resolve, reject) => {
            resolve('p1 成功状态')
        })

        new Promise((resolve, reject) => {
            resolve(p1)
        }).then(value => {
            console.log(value)  // p1成功状态
        }, reason => {
            console.log(reason)
        })
        

        //Promise.then() 方法返回的是一个新的 Promise 对象
    </script>
</body>

</html>